﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace OASystem.Controllers
{
    [App_Start.LoginFilterAtrribute]
    public class NoticeController : Controller
    {
        //
        // GET: /Notice/

        public ActionResult Index(int pageNum = 1, int pageSize = 1)
        {
            //分页查询
            var list = BLL.NoticeManager.QueryList(pageNum, pageSize);
            ViewBag.noticeList = list;
            //总的分页条
            //获取总的数据量
            var allCount = BLL.NoticeManager.QueryList().Count;

            var allPage = 0;

            if (allCount % pageSize == 0)
                allPage = allCount / pageSize;
            else
                allPage = allCount / pageSize + 1;

            ViewBag.allpage = allPage;
            ViewBag.pageNum = pageNum;
            return View();
        }

        public ActionResult Insert() { return View(); }


        [ValidateInput(false)]
        public JsonResult InsertNotice(string Title, string Content)
        {
            return Json(new BLL.NoticeManager().Insert(new Model.OA_Notice() { Title = Title, Content = Content }));

        }
        public ActionResult Detaile(int id)
        {
            //BLL.NoticeManager.QueryList().Where(n => n.Id == id).FirstOrDefault()
            return View();
        }

    }
}
